function out = doReducedFormAnalysis(outEstim)

% Unfold
model        = outEstim.model;
ySimAsInData = outEstim.outFilter.ySimAsInData;
xSim         = outEstim.outFilter.outSim.x_cu;
%model.maturities
% Level factor: (r^(1) + r^(8) + r^(40))/3
level  = (ySimAsInData(5,:)+ySimAsInData(7,:)+ySimAsInData(10,:))/3;

% Slope factor: r^(40) - r^(1) 
slope  = ySimAsInData(10,:)-ySimAsInData(5,:);

% Curvature factor: r^(8)-r^(1) - (r^(40)-r^(8)) = 2*r^(8) - r^(1) - r^(40)
curvature = 2*ySimAsInData(7,:)-ySimAsInData(5,:)-ySimAsInData(10,:);

% For preference shocks, we replace epsilond by d_cu
%posD         = find(strcmp(model.labelx,{'$d_{t}$'}));
%xSim(posD,:) = xSim(posD,:);

% The regressors
Xreg = xSim;
T    = length(slope);

% Regressions
tmp                   = nwest(level',[ones(1,T); Xreg]',0);
out.levelONx_reg.beta = tmp.beta;
out.levelONx_reg.R2   = tmp.rsqr;
tmp                   = nwest(level',[ones(1,T); Xreg; Xreg.^2]',0);
out.levelONxANDx2_reg.beta= tmp.beta;     
out.levelONxANDx2_reg.R2  = tmp.rsqr;     

tmp                   = nwest(slope',[ones(1,T); Xreg]',0);
out.slopeONx_reg.beta = tmp.beta;     
out.slopeONx_reg.R2   = tmp.rsqr; 
tmp                   = nwest(slope',[ones(1,T); Xreg; Xreg.^2]',0);
out.slopeONxANDx2_reg.beta = tmp.beta;          
out.slopeONxANDx2_reg.R2   = tmp.rsqr; 

tmp                   = nwest(curvature',[ones(1,T); Xreg]',0);
out.curvatureONx_reg.beta = tmp.beta;
out.curvatureONx_reg.R2   = tmp.rsqr; 
tmp                   = nwest(curvature',[ones(1,T); Xreg; Xreg.^2]',0);
out.curvatureONxANDx2_reg.beta = tmp.beta;
out.curvatureONxANDx2_reg.R2   = tmp.rsqr;

% Specific regressions
posMUZ     = find(strcmp(model.labelx,{'$\mu _{z,t}$'}));
posD       = find(strcmp(model.labelx,{'$d_{t}$'}));
posN       = find(strcmp(model.labelx,{'$n_{t}$'}));
posPaistar = find(strcmp(model.labelx,{'$\pi^*_{t}$'}));
posA       = find(strcmp(model.labelx,{'$a_{t}$'}));

tmp                             = nwest(level',[ones(1,T); Xreg(posD,:)]',0);
out.levelONd_reg.beta           = tmp.beta;
out.levelONd_reg.R2             = tmp.rsqr;
tmp                             = nwest(level',[ones(1,T); Xreg(posN,:)]',0);
out.levelONn_reg.beta           = tmp.beta;
out.levelONn_reg.R2             = tmp.rsqr;
tmp                             = nwest(level',[ones(1,T); Xreg(posD,:);Xreg(posN,:)]',0);
out.levelONd_n_reg.beta         = tmp.beta;
out.levelONd_n_reg.R2           = tmp.rsqr;
tmp                             = nwest(level',[ones(1,T); Xreg(posD,:);Xreg(posN,:);Xreg(posPaistar,:)]',0);
out.levelONd_n_paistar_reg.beta = tmp.beta;
out.levelONd_n_paistar_reg.R2   = tmp.rsqr;

tmp                             = nwest(slope',[ones(1,T); Xreg(posA,:)]',0);
out.slopeONa_reg.beta           = tmp.beta; 
out.slopeONa_reg.R2             = tmp.rsqr;
tmp                             = nwest(slope',[ones(1,T);Xreg(posA,:); Xreg(posD,:)]',0);
out.slopeONa_d_reg.beta         = tmp.beta;
out.slopeONa_d_reg.R2           = tmp.rsqr;
tmp                             = nwest(slope',[ones(1,T);Xreg(posA,:); Xreg(posD,:); Xreg(posN,:);Xreg(1,:)]',0);
out.slopeONa_d_n_c1_reg.beta    = tmp.beta;
out.slopeONa_d_n_c1_reg.R2      = tmp.rsqr;

tmp                             = nwest(curvature',[ones(1,T); Xreg(posPaistar,:)]',0); 
out.curvatureONpaistar_reg.beta = tmp.beta;   
out.curvatureONpaistar_reg.R2   = tmp.rsqr;
tmp                             = nwest(curvature',[ones(1,T); Xreg(posPaistar,:);Xreg(posN,:)]',0);
out.curvatureONpaistar_n_reg.beta = tmp.beta;
out.curvatureONpaistar_n_reg.R2   = tmp.rsqr;


end